﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ehost
{
    public partial class updateHostForm : Form
    {
        private mainForm mainform;

        public updateHostForm(mainForm form)
        {
            mainform = form;
            InitializeComponent();
            textBox1.Text = mainform.getTreeView().SelectedNode.Text;           
        }

        private void button1_Click(object sender, EventArgs e)
        {
            TreeNode select = mainform.getTreeView().SelectedNode;
            String content = textBox1.Text;

            if (select.Text.Equals(content))
            {

            }
            else if (select.Level == 0)
            {
                select.Text = content;
                
                foreach(TreeNode tn in select.Nodes)
                {
                    Host host=(Host)tn.Tag;
                    host.domain = content;
                    mainform.addChange(host.lineNum, host);
                }
               
            }
            else if (select.Level == 1)
            {
                Host host = (Host)select.Tag;
                host.ip = content;
                select.Text = content;
                mainform.addChange(host.lineNum, host);
            }
            Close();
        }

        private void updateHostForm_Load(object sender, EventArgs e)
        {

        }

       
    }
}
